package com.qf.cx.simplenms.readergroup.tag;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ReaderGroupTags {

	private String readerGroupName;
	// key = tid
	private final Map<String, ReaderGroupTag> map = new HashMap<>();

	public String getReaderGroupName() {
		return readerGroupName;
	}

	public void setReaderGroupName(String readerGroupName) {
		this.readerGroupName = readerGroupName;
	}

	public void add(ReaderGroupTag e) {
		ReaderGroupTag readerGroupTag = map.get(e.getTid());
		if (readerGroupTag != null) {
			readerGroupTag.mergeStatistics(e.getStatistics());
		} else {
			map.put(e.getTid(), e);
		}
	}

	public List<ReaderGroupTag> getTags() {
		Collection<ReaderGroupTag> values = map.values();
		return new ArrayList<>(values);
	}

	@Override
	public String toString() {
		return "ReaderGroupTags [readerGroupName=" + readerGroupName + ", map=" + map + "]";
	}
	
}
